package com.ptmall.app.ui.adapter;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.ptmall.app.R;
import com.ptmall.app.bean.ShopCarBean;
import com.ptmall.app.bean.model.HomePageIndex;
import com.ptmall.app.net.HttpMethods;
import com.ptmall.app.ui.activity.GoodDetilActivity;
import com.ptmall.app.utils.GlideUtil;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by zjh on 2016/9/23.
 * 新品推荐
 */
public class GoodDetilimgreAdapter extends RecyclerView.Adapter<GoodDetilimgreAdapter.ViewHolder> {

    private Activity mActivity;
    private List<HomePageIndex.SlideBean> mDataList = new ArrayList();

    public GoodDetilimgreAdapter(Activity mActivity) {
        this.mActivity = mActivity;
    }

    public void bind(List<HomePageIndex.SlideBean> mData) {
        this.mDataList = mData;
    }

    public interface Click{
        void addcarimg(ImageView iv, String id, String num);

    }

    public Click click;

    public void setClick(Click click) {
        this.click = click;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_gooddetil, parent, false);
        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(final ViewHolder viewHolder, int position) {
//        GlideUtil.showImg(mActivity,mDataList.get(position).getImage_path(),viewHolder.img);

        Glide.with(mActivity).load(HttpMethods.BASEIMG_URL+mDataList.get(position).getImage_path()).dontAnimate()
                .placeholder(R.drawable.z2).error(R.drawable.z2).into(viewHolder.img);


    }

    @Override
    public int getItemCount() {
        return mDataList.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

        ImageView img;

        public ViewHolder(View view) {
            super(view);

            img = (ImageView) view.findViewById(R.id.img);

        }
    }


}
